/**
 * 游戏背景类
 */
class Background extends Laya.Sprite {
    private bg1: Laya.Sprite;
    private bg2: Laya.Sprite;
    private bg_height: number = 852;
    constructor() {
        super();
        this.init();
    }

    init():void {
        this.bg1 = new Laya.Sprite();
        this.bg1.loadImage('war/background.png');
        this.addChild(this.bg1);

        this.bg2 = new Laya.Sprite();
        this.bg2.loadImage('war/background.png');
        this.bg2.pos(0, -this.bg_height);
        this.addChild(this.bg2);
        Laya.timer.frameLoop(1, this, this.loopBg);
    }
    //以帧循环设置背景图片滚动
    loopBg():void {
        let t_bg_height: number = this.bg_height;
        if(++this.bg1.y >= t_bg_height) {
            this.bg1.y = -t_bg_height;
        } 
        if(++this.bg2.y >= t_bg_height) {
            this.bg2.y = -t_bg_height;
        } 
    }
}